//
//  LevelScene.h
//  NinjaTurtle
//
//  Created by Nguyen Tri Chung on 2/16/15.
//
//

#ifndef __NinjaTurtle__LevelScene__
#define __NinjaTurtle__LevelScene__

#include <stdio.h>
#include "cocos2d.h"
#include "../model/model.h"
#include "../support/support.h"
#include "TextDialogLayer.h"

USING_NS_CC;

class LevelScene : public Scene, public View {
protected:
    GameEventListener* gameEventListener;
    EventListenerTouchOneByOne* touchListener;
    EventListenerKeyboard* keyBoardListener;
    bool preparingPlayGame;
    
    Layer* backgroundLayer;
    Layer* guiLayer;
    TextDialogLayer* dialogLayer;
    
    Label* titleLabel;

    CSprite* logoFace;
    vector<float> targetJumpHeights;
    int currentTargetJumpHeightIndex;
    float currentJumpTime;
    float lastStepY;
    Point logoLandPos;
    
    Turtle* introTurtle;
    Point introTurtleLandPos;
    
    vector<string> commandList;
    int currentCommandIndex;
    Label* commandButton;
    CSprite* previousCommand;
    CSprite* nextCommand;
public:
    LevelScene();
    virtual ~LevelScene();
    void disposeComponents();
    void onExit();
    
    void inialize();
    void createLayers();
    void createLayersContent();
    void processEvent(GameEvent* event);
    virtual void update(float dt);
    
    bool onTouchBegan(Touch* touch, Event* event);
    void onTouchMoved(Touch* touch, Event* event);
    void onTouchEnded(Touch* touch, Event* event);
    void onTouchCancelled(Touch* touch, Event* event);
    
    void onKeyPress(EventKeyboard::KeyCode keyCode, Event* event);
    void onKeyRelease(EventKeyboard::KeyCode keyCode, Event* event);
    
    void changeCommand(bool next);
    void updateCommandText();
    void onFunctionCallback(int code);
    void addSpriteToLayer(Obj* object, Layer* layer, int index);
};

#endif /* defined(__NinjaTurtle__LevelScene__) */
